home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / elk-2_0.lha / elk-2.0 / contrib / zelk / src-zelk / zelk.h < prev   
Encoding:
C/C++ Source or Header  |  1992-11-12  |  5.3 KB  |  185 lines

  1. /* zelk.h zilla 19aug91 - extensions to elk
  2.  * modified
  3.  * 12nov
  4.  * 20sep
  5.  * 6apr         farray->shape,ndim
  6.  */
  7.  
  8. /* ZELK is defined in the config system file */
  9. #ifdef ZELK  /*%%%%%%%%%%%%%%%%*/
  10.  
  11. #ifndef ZELK_H        /* do not include twice */
  12. #define ZELK_H
  13.  
  14. /* some additional prototypes? no-let elk declare them */
  15. /*#include <elk_protos.h>*/
  16.  
  17. /*%%%% these options are configured in config/system %%%%*/
  18.  
  19. /*#define ELKVECTOR        /+ include vector primitives? (requires ANSI C) */
  20.  
  21. /*#define ZILLAONLY        /+ include graphics extensions? */
  22.  
  23. /* see math.c.  Elk math has several characteristics which are altered
  24.  * as follows:
  25.  *- (/ x y) when both x,y are integer is treated as if x,y are both
  26.  *  real, e.g. (/ 5 3) => 1.6666.  Xscheme and Scm also act this way;
  27.  *  vscm has (/ 5 3) => 1 (integer).
  28.  *  ZELK_INTEGER_DIV changed this so that (/ 5 3) => 1 (as in C).
  29.  */
  30. #define ZELK_INTEGER_DIV 0
  31.  
  32. /*- Real numbers equal to integers become integers, 
  33.  *  e.g. (/ 6. 3.) => 2 (integer); (type 2.0) => integer
  34.  *  ZELK_CONTAGIOUS_FLT makes floats 'contagious'.
  35.  */
  36. #define ZELK_CONTAGIOUS_FLT 1
  37.  
  38. /*%%%% end of configure %%%%*/
  39.  
  40. #define ELKV2 1         /* elk version 2+? */
  41.  
  42. #if (!ZILLAONLY)
  43. # define str_cat strcat
  44. # define str_cpy strcpy
  45. # define str_len strlen
  46. # define str_eq(a,b) (strcmp(a,b)==0)
  47. #endif
  48.  
  49. #if ZILLAONLY
  50. /* this will not be used unless zelk is included e.g. in print.c */
  51. /*# undef FLONUM_FORMAT*/
  52. /*# define FLONUM_FORMAT "%g"*/
  53. # undef HEAP_SIZE
  54. # define HEAP_SIZE 2048
  55. #endif
  56.  
  57. #ifndef THEUSUAL_H
  58. # include <theusual.h>
  59.   /* some of the zelk extensions use proc as a synonym for void, 
  60.      whereas some of the elk sources use proc as a variable name.
  61.      wrap this inside 'ifndef THEUSUAL_H': all zelk source
  62.      which will later need proc should include theusual.h before
  63.      including scheme.h.
  64.      For Elk source, scheme.h is included & THEUSUAL_H is not defined
  65.      until now.  Use this to #undef proc at the end of this file,
  66.      to prevent conflicts.
  67.    */
  68. # define undo_proc /*see end of this file */
  69. #endif /*theusual.h*/
  70.  
  71. /* foreign functions */
  72. #include <rtlpkg.h>
  73.  
  74. /* T_Double.
  75.  * this is not a real elk type--it is used only by foreign functions
  76.  * which (with ansi C) now need to distinguish passing float vs doubles.
  77.  * This const is used only in the foreign argspec in-memory representaion.
  78.  * The external form of foreign argument specs ("ARF") get translated
  79.  * to lisp types, so F->T_Flonum, D->T_Double.  Unless T_Double is #defined
  80.  * the distinction is not made (everything passed as double).
  81.  *
  82.  * Currently fvector.c is compiled with gcc (since one of the macros
  83.  * is ansi). 
  84.  */
  85. #ifndef __GNUC__
  86. #if Esparc
  87. # if Eansi
  88.   :error examine float/double issue zelk.h
  89. # endif
  90. #endif
  91. #endif
  92.  
  93. #if Esgi
  94. # define T_Double 253
  95. #endif
  96.  
  97. /**** native function table.  similar non-global structure in prim.c */
  98. struct primdef {
  99.   Object (*fun)();
  100.   char *name;
  101.   int minargs,maxargs;
  102.   enum discipline disc;
  103. };
  104.  
  105. /**** misc. internal functions ****/
  106.  
  107. /* zelk.c */
  108. void Init_zelk(Zvoid);
  109. char *Get_Cstring P_((Object)); /* convert elk string to static c string */
  110. Dfloat Get_Flonum P_((Object));
  111. Object P_float P_((Object));
  112. void ZLprimdeftab P_((struct primdef *));
  113.  
  114. /* forfunc.c */
  115. void Init_foreign P_((Zvoid));
  116. void Define_Foreign P_((char *name,vfunction *,char *args));
  117. void Define_Fortab P_((struct fordef *));
  118. void ZLforudeftab P_((struct fordef_usage *));
  119. char *ZLforproto P_((unsigned char *));
  120. Object Pforeignprototype P_((Object));
  121. Object ZLforcall P_((char *name,function *,unsigned char *proto,
  122.                          int,Object *));
  123.  
  124. /* forpkg.c */
  125. void Init_pkg(Zvoid);
  126. Object P_LoadPkg P_((int, Object *));
  127. bool Zforpkglink P_((SYMTAB *,char *));
  128. void Zforpkginit P_((char *,PKG_type *));
  129. #if ZILLAONLY
  130. void old_linkcsubr P_((struct cfordef *));
  131. void Define_OldForeign P_((char *,vfunction *,int *));
  132. #endif
  133.  
  134. void Init_peekpoke P_((Zvoid));
  135. void Init_vector P_((Zvoid));
  136. void Init_gl P_((Zvoid));
  137. void Init_forfunctest P_((Zvoid));
  138.  
  139. /**** foreign arrays ****/
  140.  
  141. extern int T_Farray;
  142.  
  143. #define FARRAY(o) ((Farray *)POINTER(o))
  144.  
  145. #define FARRAY_MAXDIM 3
  146.  
  147. typedef struct farray {
  148.   Object tag;  /* needed by elk gc system */
  149.   int type;
  150.   int len;
  151.   int shape[FARRAY_MAXDIM];          /* shape, used by vector code.
  152.                                         inner dimension is [0].
  153.                                       */
  154.   int ndim;                          /* used by vector code */
  155.     /* magic must be immediately before start of data! */
  156.   int4 magic;           /* this is for non-scheme code which wants
  157.                            to know if an array is an farray */
  158.   Zbyte data[1];        /* first word of actual data */
  159. } Farray;
  160.  
  161.  
  162. #define TYPEORFARRAYTYPE(A) \
  163.   ((TYPE(A)==T_Farray) ? FARRAY(A)->type : TYPE(A))
  164.  
  165. #define FARRAYDATA(D,dtype) ((dtype *)FARRAY(D)->data)
  166. #define FARRAYDATAPTR(var,D,dtype) dtype *var = ((dtype *)FARRAY(D)->data)
  167.  
  168. void Init_farray P_((Zvoid));
  169. Object farray_make P_((int4 type,int4 len));
  170. Object farray_make_like P_((Object A));
  171. Object P_farray_copy P_((Object));
  172. Object P_farray_ref P_((Object,Object));
  173. void farray_copyshape P_((Object from,Object to));
  174. void farray_check P_((Object));
  175. void farray_print P_((Object,Object,bool,int,int));
  176.  
  177. /* see comment at beginning of this file */
  178. #ifdef undo_proc
  179. # undef proc
  180. # undef undo_proc
  181. #endif
  182.  
  183. #endif /*ZELK_H*/
  184. #endif /*ZELK%%%%%%%%%%%%%%%%*/
  185.